import random

def KeyGen(ACT, MK):
    d = ACT.value - 1
    y = MK[0]
    ACT.poly.append(y)
    for i in range(0, d):
        ACT.poly.append(random.randint(1, 10))
    D = []
    ACT.poly.reverse()
    print(ACT.poly)
    for index in range(len(ACT.child)):
        b = ACT.getY(index)
        GenPoly(ACT.child[index], D, b,MK)
    return D


def GenPoly(child, D, b,MK):
    child.poly.append(b)
    d = child.value - 1
    for i in range(0, d):
        child.poly.append(random.randint(1, 10))
    child.poly.reverse()
    if (child.type == 'attr'):
        Di = 11 ** (b / MK[child.value])
        D.append(Di)
        return
    lens = len(child.child)
    if lens != 0:
        for index in range(len(child.child)):
            b = child.getY(index)
            GenPoly(child.child[index], D, b,MK)



